// 不需要从服务端去获取的一些表单选项
import { i18n } from '@/i18n';
import {
  ProductKeyM1,
  ProductKeyM1V1,
  ProductKeyM1V2,
  ProductKeyM2, ProductKeyM2V1, ProductKeyM2V2, ProductKeyMCM1, ProductKeyQCGW,
  ProductKeyVI1,
  ProductKeyVI2
} from "@/consts/product";

export const IsLora = (deviceNo:any) => {
  if(!deviceNo){
    return false;
  }
  return deviceNo.toString().toLowerCase().includes("lora")
}

export const IsBelongM1 = (productKey:string)=>{
  const arr = [
    ProductKeyM1,
    ProductKeyM1V1,
    ProductKeyM1V2,
  ]
  return arr.includes(productKey.trim().toUpperCase())
}

export const IsBelongM2 = (productKey:string)=>{
  const arr = [
    ProductKeyM2,
    ProductKeyM2V1,
    ProductKeyM2V2,
  ]
  return arr.includes(productKey.trim().toUpperCase())
}

export const IsBelongAe = (productKey:string)=>{
  const arr = [
    ProductKeyM1,
    ProductKeyM2,
    ProductKeyM1V1,
    ProductKeyM1V2,
    ProductKeyM2V1,
    ProductKeyM2V2
  ]
  return arr.includes(productKey.trim().toUpperCase())
}

export const IsBelongVI = (productKey:string)=>{
  const arr = [
    ProductKeyVI1,
    ProductKeyVI2,
    ProductKeyM1V1,
    ProductKeyM1V2,
    ProductKeyM2V1,
    ProductKeyM2V2
  ]
  return arr.includes(productKey.trim().toUpperCase())
}

export const IsBelongVI1 = (productKey:string)=>{
  const arr = [
    ProductKeyVI1,
    ProductKeyM1V1,
    ProductKeyM2V1,
  ]
  return arr.includes(productKey.trim().toUpperCase())
}

export const IsBelongVI2 = (productKey:string)=>{
  const arr = [
    ProductKeyVI2,
    ProductKeyM1V2,
    ProductKeyM2V2
  ]
  return arr.includes(productKey.trim().toUpperCase())
}

export const getProductKeys = async ()=>{
  const i18nObj = i18n.global
  const res = [
    {val: ProductKeyM1, label:ProductKeyM1},
    {val: ProductKeyM2, label:ProductKeyM2},
    {val: ProductKeyVI1, label:ProductKeyVI1},
    {val: ProductKeyVI2, label:ProductKeyVI2},
    {val: ProductKeyM1V1, label:ProductKeyM1V1},
    {val: ProductKeyM1V2, label:ProductKeyM1V2},
    {val: ProductKeyM2V1, label:ProductKeyM2V1},
    {val: ProductKeyM2V2, label:ProductKeyM2V2},
    {val: ProductKeyQCGW, label:i18nObj.t('products.productPage.ProductKeyQCGW')},
    {val: ProductKeyMCM1, label:i18nObj.t('products.productPage.ProductKeyMCM1')},
  ]
  return Promise.resolve(res)
}

// 存储地方
export const getStorageLocationOptions = async ()=>{
  const res = [
    {val: 0, label:"local"},
    {val: 1, label:"oss"},
  ]
  return Promise.resolve(res)
}

//产品激活选项
export const getProductOpenStatusOptions =  async ()=>{
  const i18nObj = i18n.global
  const res = [
    {val: 0, label:i18nObj.t('products.productPage.inactive')},
    {val: 1, label:i18nObj.t('products.productPage.active')},
  ]
  return Promise.resolve(res)
}

// 设备在线状态
export const getDeviceStatusOptions =  async ()=>{
  const i18nObj = i18n.global
  const res = [
    {val: 1, label:i18nObj.t('products.productPage.offline')},
    {val: 2, label:i18nObj.t('products.productPage.online')},
  ]
  return Promise.resolve(res)
}

export const getNetworkTypeOptions = async ()=>{
  const res = [
    {val: 1, label:"4G"},
    {val: 2, label:"LORA"},
  ]
  return Promise.resolve(res)
}
